package com.example.day6.View;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.day6.Model.Bean;
import com.example.day6.Model.NetModel;
import com.example.day6.Presener.NetPresener;
import com.example.day6.R;

import java.util.ArrayList;

public class FragmentA extends Fragment {

    private RecyclerView r;
    private View view;
    private ArrayList<Bean.DataBean.DatasBean> list;
    private RAdapter adapter;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        view = LayoutInflater.from(getContext()).inflate(R.layout.layout_fragment_a, null);
        r = view.findViewById(R.id.fragment_a_recycler);

        r.setLayoutManager(new LinearLayoutManager(getContext()));

        list = new ArrayList<>();

        adapter = new RAdapter(getContext(), list);
        r.setAdapter(adapter);

        initData();
        return view;
    }
        //A0:1E:E5:6B:02:76:E6:2C:1E:21:4D:78:E4:8C:AF:BE:3C:2E:BA:4A
    int page = 1;

    private void initData() {

        NetPresener netPresener = new NetPresener();
        netPresener.initData(new NetView() {
            @Override
            public void getData(Bean bean) {
                    adapter.addData(bean.getData().getDatas());
            }
        }, page);


    }
}
